{extend name='./content'}

{block name="content"}

<!-- 表单搜索 开始 -->
<nav class="ns-third-menu js-order-status-menu">
    <ul id="order_status_nav" data-menu-node="m-117-118">
        <li class="nav-item {if path('code')==''}selected{/if}">
            <a data-menu-node='m-117-137' data-open="admin.html#/admin/goods/code.html">正常源码</a>
        </li>
        <li class="nav-item {if path('code')=='down'}selected{/if}">
            <a data-menu-node='m-117-137' data-open="admin.html#/admin/goods/code/down.html">下架源码</a>
        </li>
        <li class="nav-item {if path('code')=='audit'}selected{/if}">
            <a data-menu-node='m-117-137' data-open="admin.html#/admin/goods/code/audit.html">审核源码</a>
        </li>
        <li class="fr">
            <div>统计金额 <span>{$sum_money|default="0"}</span> 元</div>
        </li>
        <li class="fr">
            <div>商品数量 <span>{$sum_order|default="0"}</span> 个</div>
        </li>
    </ul>
</nav>

<form class="layui-form  form-search" action="__SELF__" onsubmit="return false" method="get">
    <div class="layui-form-item layui-inline">
        <button id="go_down" type="button" class="layui-btn layui-btn-normal layui-btn-small">批量上下架</button>
        <button id="go_true" type="button" class="layui-btn layui-btn-normal layui-btn-small">批量通过</button>
        <button id="go_del" type="button" class="layui-btn layui-btn-normal layui-btn-small">批量删除</button>
    </div>
    <div class="fr search_normal">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">商品名</label>
            <div class="layui-input-inline">
                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入商品名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <button type="submit" class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon">&#xe615;</i> 搜 索</button>
        </div>
        <div class="layui-form-item layui-inline">
            <button type="button" value="搜索" class="layui-btn btn-common btn_more_go layui-btn-small">高级搜索</button>
        </div>
    </div>
</form>
<form class="layui-form  form-search" action="__SELF__" onsubmit="return false" method="get">

<!--    hide start -->
    <div class="hide code_more">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">商户ID</label>
            <div class="layui-input-inline">
                <input name="user_id" value="{$Think.get.user_id|default=''}" placeholder="请输入商户ID" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">商户账号</label>
            <div class="layui-input-inline">
                <input name="username" value="{$Think.get.username|default=''}" placeholder="请输入商户账号" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">商品名</label>
            <div class="layui-input-inline">
                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入商品名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="status">
                    <option value="">全部状态</option>
                    <option value="0" {if $Think.get.zt === '0'}selected{/if}>待审核</option>
                    <option value="1" {if $Think.get.zt === '1'}selected{/if}>已通过</option>
                    <option value="2" {if $Think.get.zt === '2'}selected{/if}>未通过</option>
                    <option value="1" {if $Think.get.zt === '1'}selected{/if}>已上架</option>
                    <option value="0" {if $Think.get.zt === '0'}selected{/if}>已下架</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">时间范围</label>
            <div class="layui-input-inline">
                <input name="date_range" id="date_range" value="{:urldecode($Think.get.date_range)}" placeholder="请选择时间范围" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <button type="submit" class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            <button type="submit" class="layui-btn btn-common btn_more_over layui-btn-small">收 起</button>
        </div>
    </div>
<!--hide start in-->
</form>
<!-- 表单搜索 结束 -->



<form onsubmit="return false;" data-auto="true" method="post">
    <input type="hidden" value="resort" name="action"/>
    <table class="table table-hover">
        <thead>
        <tr>
            <th class='list-table-check-td'>
                <input data-none-auto="" data-check-target='.list-check-box' type='checkbox' />
            </th>
            <th>商品缩略图</th>
            <th>分销</th>
            <th>商户名称</th>
            <th>商品价格</th>
            <th>商品销量</th>
            <th>审核状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $data as $v}
        <tr>
            <td class='list-table-check-td'>
                <input class="list-check-box" value='{$v.id}' type='checkbox' />
            </td>
            <td class="goods-info" style="width: 30%">
                <div class="goods-img">
                    <a target="_blank" href="{:sysconf('site_domain')}/code/goods{$v.id}.html">
                        <img src="{:get_tp($v.bh)}" alt="">
                    </a>
                </div>
                <div class="info-wrap">
                    <div class="info">
                        <span class="c_text">创建时间：</span><span class="c_time">{$v.sj}</span>
                        <span class="div-flag-style">
											<i class="iconfont iconerweima goods-qrcode"></i>
											<div class="QRcode" style="display: none;">
												<p><img src="/upload/goods_qrcode/goods_qrcode_384.png" style="width:110px;"></p>
											</div>
										</span>
                    </div>
                    <a target="_blank" href="{:sysconf('site_domain')}/code/goods{$v.id}.html">
                        <p class="goods-name">{:changdu($v.tit,100)}</p>
                    </a>
                    <div class="line-height-none clearfix">
                        <p class="goods-introduction"></p>

                    </div>
                    <div class="line-height-none">
                        <span class="goods-label" onclick="cancelLabelRecommend(384,'label','4')" title="点击取消该标签">一体式</span><span class="goods-label" onclick="cancelLabelRecommend(384,'label','5')" title="点击取消该标签">节能环保</span><span class="free-shipping">包邮</span>
                    </div>
                </div>
            </td>
            <td>
                <div class="fx-info"><p>是否开启分销 <span class="status-mark not-opened">未开启</span></p><p>分销佣金比率：0.00%</p><p>股东分红比率：0.00%</p><p>区域分销比率：0.00%</p></div>
            </td>
            <td>{:uc_info($v.ubh,'sell','name')}</td>
            <td class="money">{$v.money}.00</td>
            <td>10</td>
            <td>
                {if $v.zt==0 || $v.zt==3}
                <span style="color:red"><i class="glyphicon glyphicon-remove"></i> 未审核</span>
                {/if}
	            {if $v.zt==1}
				<span style="color:green"><i class="glyphicon glyphicon-ok"></i> 已审核</span>
                {/if}
                {if $v.zt==2}
                <span style="color:red"><i class="glyphicon glyphicon-remove"></i> 已下架</span>
                {/if}
                <!--span style="color:green"><i class="glyphicon glyphicon-ok"></i> 已上架</span>
                <a class="btn btn-danger btn-xs text-white" data-tips="确定下架该商品吗？ " data-update="{$v.id}" data-field='status' data-value='0' data-action='{:url("change_status")}'href="javascript:void(0)">下架</a-->		
			</td>
            <td>
                <a onclick="del(this,'{$v.bh}','code')">删除</a>
                <a href="{:url("manage/user/login")}?bh={$v.ubh}" target="_blank">登录</a>
                {if $v.zt==0 || $v.zt==3}
                <a  data-tips="确定审核通过该商品吗？" data-update="{$v.id}" data-field='code' data-value='1' data-action='{:url("change_freeze")}'href="javascript:void(0)">通过</a>{/if}
                {if $v.zt==1}
                <a  data-tips="确定审核不通过该商品吗？ " data-update="{$v.id}" data-field='code' data-value='0' data-action='{:url("change_freeze")}'href="javascript:void(0)">不通过</a>{/if}
                {if $v.zt==2}
                <a  data-tips="确定上架该商品吗？" data-update="{$v.id}" data-field='code' data-value='1' data-action='{:url("change_status")}'href="javascript:void(0)">上架</a>{/if}
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
</form>
{$page}
<script>
    layui.use('form', function(){
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#date_range',
            range: true
        });
    });

    function del(obj,bh,type) {
        layer.confirm('确定删除？删除后，商品将进入回收站！',function(val){
            if(val){
                $.post('/admin/goods/del',{
                    bh:bh,
					type:type
                },function(res){
                    if(res.code!=200){
                        layer.msg('删除失败');
                    }else{
                        layer.msg('删除成功！',function(){
                            location.reload();
                        });
                    }
                });
            }
        })
    }

    $('img').on('click', function () {
		layer.photos({
			photos: '.layui-table',
			shadeClose: false,
			closeBtn: 2,
			anim: 0
		});
	})
    // 批量上架
    $('#go_down').click(function () {
        var ids = '';
        $('.list-check-box').each(function () {
            var _this = $(this);
            if (_this.is(':checked')) {
                ids = ids + _this.val() + ',';
            }
        });
        layer.confirm('确定要批量上架吗', function (index) {
            if (ids == '') {
                layer.msg('请选择操作商品');
                return false;
            }
            $.ajax({
                url: "/admin/goods/go_down",
                type: 'post',
                data: {
                    'ids' : ids,
					'type': 'code'
                },
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                        $.form.reload();
                    } else {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    }
                }
            });
        });
    });
    // 批量通过
    $('#go_true').click(function () {
        var ids = '';
        $('.list-check-box').each(function () {
            var _this = $(this);
            if (_this.is(':checked')) {
                ids = ids + _this.val() + ',';
            }
        });
        layer.confirm('确定要批量通过吗', function (index) {
            if (ids == '') {
                layer.msg('请选择操作商品');
                return false;
            }
            $.ajax({
                url: "/admin/goods/go_true",
                type: 'post',
                data: {
                    'ids' : ids,
					'type': 'code'
                },
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                        $.form.reload();
                    } else {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    }
                }
            });
        });
    });

    // 批量删除
    $('#go_del').click(function () {
        var ids = '';
        $('.list-check-box').each(function () {
            var _this = $(this);
            if (_this.is(':checked')) {
                ids = ids + _this.val() + ',';
            }
        });
        layer.confirm('确定要批量删除吗', function (index) {
            if (ids == '') {
                layer.msg('请选择操作商品');
                return false;
            }
            $.ajax({
                url: "/admin/goods/go_del",
                type: 'post',
                data: {
                    'ids' : ids,
					'type': 'code'
                },
                success: function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                        $.form.reload();
                    } else {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        });
                    }
                }
            });
        });
    });
    $('.btn_more_go').click(function (){
        $('.code_more').removeClass('hide');
        $('.search_normal').addClass('hide')
    })
    $('.btn_more_over').click(function (){
        $('.code_more').addClass('hide')
        $('.search_normal').removeClass('hide')
    })
</script>
{/block}
